package com.study.mybatis.dao;

import com.study.mybatis.entity.Class;
import com.study.mybatis.entity.Student;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.cache.decorators.LruCache;
import org.apache.ibatis.cache.impl.PerpetualCache;

import java.util.List;

/**
 * @author wei.zhao
 * @date 2021年11月25日 14:21
 */
public interface StudentDao2 {
    /*一对一*/
    Student oneToOne(Long id);

    /*一对多*/
    Class oneToMany(Long id);

    /*一对一，支持延迟加载*/
    Student oneToOneLazy(Long id);

    /*一对多，支持延迟加载*/
    Class oneToManyLazy(Long id);

    /*根据班级id查询班级*/
    Class findClassById(Long id);

    /*根据班级id查询学生*/
    List<Student> findStudentsByClassId(Long id);

    @Insert("insert into t_student (name,age) values (#{name},#{age})")
    void insertStudent(Student student);

    void insertStudent2(Student student);

    @Select("select * from t_student")
    List<Student> queryAll();

    void insertClass(Class aClass);

    Class queryClassById(Long id);
}
